//
//  CheckCodeTableViewCell.m
//  OneCreditTreasure
//
//  Created by iOS Tedu on 16/9/2.
//
//

#import "CheckCodeTableViewCell.h"

@implementation CheckCodeTableViewCell
#pragma mark - 生命周期 life cycle
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self leftInfoLB];
        [self inputTF];
        [self checkCodeBtn];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

#pragma mark - 方法 methods
- (void)showMsg:sender {
    [self.delegate getCheckCode:self];
}

#pragma mark - 懒加载 lazy loading
- (UILabel *)leftInfoLB {
    if(_leftInfoLB == nil) {
        _leftInfoLB = [[UILabel alloc] init];
        [self.contentView addSubview:_leftInfoLB];
        [_leftInfoLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(12);
            make.top.equalTo(4);
            make.bottom.equalTo(-4);
            make.width.equalTo(kScreenW / 4);
        }];
        _leftInfoLB.font = defaultFont;
    }
    return _leftInfoLB;
}

- (UITextField *)inputTF {
    if(_inputTF == nil) {
        _inputTF = [[UITextField alloc] init];
        _inputTF.clearButtonMode = UITextFieldViewModeWhileEditing;
        [self.contentView addSubview:_inputTF];
        [_inputTF mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.leftInfoLB.mas_right).equalTo(0);
            make.top.equalTo(4);
            make.bottom.equalTo(-4);
            make.right.equalTo(self.checkCodeBtn.mas_left).equalTo(0);
        }];
        _inputTF.placeholder = @"请输入您的手机号码";
        _inputTF.returnKeyType = UIReturnKeyNext;
        _inputTF.clearButtonMode = UITextFieldViewModeWhileEditing;
        _inputTF.font = defaultFont;
    }
    return _inputTF;
}

- (UIButton *)checkCodeBtn {
    if(_checkCodeBtn == nil) {
        _checkCodeBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.contentView addSubview:_checkCodeBtn];
        [_checkCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(-12);
            make.top.equalTo(4);
            make.bottom.equalTo(-4);
            make.width.equalTo(75);
        }];
        [_checkCodeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
        myBtnSettings(1, [[UIColor blackColor] CGColor], [UIColor blackColor], 6, _checkCodeBtn)
        [_checkCodeBtn.titleLabel setFont:[UIFont systemFontOfSize:14 * AUTO_WIDTH]];
        [_checkCodeBtn addTarget:self action:@selector(showMsg:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _checkCodeBtn;
}
@end
